package com.example.xViewChat.UI.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.xViewChat.R;
import com.example.xViewChat.UI.MsgActivity;
import io.ganguo.chat.core.util.DateUtils;
import io.ganguo.chat.route.biz.entity.Message;

import java.util.List;

/**
 * Created by hasee on 2016-04-10.
 */
public class MsgListViewAdapter extends BaseAdapter {
    public List<Message> getList() {
        return list;
    }

    public void setList(List<Message> list) {
        this.list = list;
    }

    protected List<Message> list;
    protected MsgActivity scactivity;
    int faceSize = 30;

    public MsgListViewAdapter(MsgActivity context, List<Message> list) {
        super();
        this.scactivity = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Message getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final Message msg = getItem(position);


        convertView = LayoutInflater.from(scactivity).inflate(R.layout.item_chat_sysmsg, null);


        ((TextView) convertView.findViewById(R.id.textMsgType)).setText("系统消息");

        ((TextView) convertView.findViewById(R.id.time)).setText(DateUtils.date2str(msg.getCreateAt()));

        ((TextView) convertView.findViewById(R.id.content)).setText(msg.getMessage());
        ((ImageView) convertView.findViewById(R.id.headImageView)).setImageResource(R.drawable.icon_recent_sysmsg);

        return convertView;
    }
}
